import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;

public class Language extends Canvas{
	private Display display;
	private Sound sound;
	public Language(GameMIDlet midlet, Display display){	
		this.display = display;
		sound = new Sound(midlet, display);
		setFullScreenMode(true);
	}	
	protected void paint(Graphics g){
		g.setColor(255, 255, 255);		
		g.fillRect(0, 0, 128, 160);
		//g.drawLine(64,0,64,160);
		g.setColor(255, 240, 160);
		if(Option.language  == true){
			//dong duoi dung de ve dong mau sang,			
			g.fillRect(0, 23, 128, 15);					
			//con 2 dong tiep theo chi ve nhung mui ten don gian, chon cach nao cung duoc
			//g.drawString(">>>", 19, 25, 0);
			//g.drawString("<<<", 90, 25, 0);
		}
		else{
			//dong duoi dung de ve dong mau sang,			
			g.fillRect(0, 38, 128, 15);
			//con 2 dong tiep theo chi ve nhung mui ten don gian, chon cach nao cung duoc
			//g.drawString(">>>", 25, 40, 0);
			//g.drawString("<<<", 83, 40, 0);
		}
		g.setColor(0, 0, 0);			
		g.drawString("Tieng Viet", 39, 25, 0);	
		g.drawString("English", 49, 40, 0);	
	}
	protected void keyPressed(int code){
		//Xu ly hien thi khi chon ngon ngu
		if((code == 53)||(code == -5)){				
			//Sau khi chon ngon ngu la load goi ngon ngu
			display.setCurrent(sound);			
		}
		//Xu ly hien thi khi nhan len
		if((code == 50)||(code == -1)){
			if(Option.language == true)
				Option.language = false;
			else
				Option.language = true;
		}
		//Xu ly hien thi khi nhan xuong
		if((code == 56)||(code == -2)){
			if(Option.language == true)
				Option.language = false;
			else
				Option.language = true;
		}
		repaint();
	}
}